<template>
	<view class="page">
		<navigation class="header_navigation" barColor="#333333" textColor="#333333" defaultButton="back">{{detail.beadHouseName}}</navigation>
		<scroll-view scroll-y="true" class="page_scroll" scroll-with-animation="true" enable-back-to-top="true">
			<view class="header">
				<swiper class="header_swiper" :current="swiperCurrent" @change="changeSwiper" :indicator-dots="false" :autoplay="true"
				 :interval="3000" :duration="1000" :circular="true">
					<swiper-item v-for="(item,index) in detail.images" :key="index">
						<view class="swiper-item">
							<image class="image" :src="item" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
				<view class="dots" v-if="detail.images && detail.images.length>1">
					<block v-for="(item,index) in detail.images.length" :key="item">
						<view class="dot" :class="index==swiperCurrent ? ' active' : ''"></view>
					</block>
				</view>
			</view>
			<view class="intro">
				<view class="title">养老院简介</view>
				<view class="text">
					{{detail.beadHouseContent}}
				</view>
			</view>
			<view class="intro">
				<view class="title">养老院服务</view>
			</view>
			<view class="card_panel">
				<view class="card_item" v-for="(item,index) in detail.list" :key="index">
					<image class="card_image" :src="item.beadHouseDetailsImg" mode=""></image>
					<view class="card_text">{{item.beadHouseDetailsName}}</view>
				</view>
			</view>
		</scroll-view>

	</view>
</template>

<script>
	import * as modelApi from '@/api/userApi/model.js'
	export default {
		data() {
			return {
				swiperCurrent: 0,
				id: '',
				detail: {
					beadHouseName: '',
					beadHouseImage:[],
					list: [],
				}
			};
		},
		methods: {
			changeSwiper(e) {
				this.swiperCurrent = e.detail.current;
			},
			getDetail(id) {
				modelApi
					.queryBasicDetails({beadHouseId:id})
					.then(res => {
						if (res.code === 0) {
							this.detail = res.data;
						}
					})
					.catch(e => {
						uni.showToast({
							title: e.msg,
							icon: 'none',
							duration: 1000
						});
					});
			},
		},
		onLoad(options) {
			if (options && options.id) {
				this.id = options.id;
				this.getDetail(options.id);
			}
		}
	}
</script>

<style lang="stylus">
	.page_scroll {
		position absolute;
		top calc(120rpx + var(--status-bar-height));
		right 0rpx;
		bottom 0rpx;
		left 0rpx;
	}

	.header {
		width: 100%;
		position: relative;

		.header_navigation {
			position: absolute;
			top: 0rpx;
			z-index 9
		}

		.header_swiper {
			width: 100%;
			height: 310rpx;
			padding 0rpx 30rpx;
			box-sizing border-box;

			.swiper-item,
			.image {
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
			}

		}

		.dots {
			position absolute;
			bottom 10rpx;
			left 50%;
			// 这里一定要注意兼容不然很可能踩坑          
			transform translate(-50%, 0);
			-webkit-transform translate(-50%, 0);
			z-index 9;
			display flex;
			flex-direction row;
			justify-content center;

			.dot {
				width: 28rpx;
				height: 8rpx;
				background rgba(196, 196, 196, 1);
				border-radius 4rpx;
				margin-right 20rpx;
			}

			.active {
				background rgba(255, 66, 0, 1);
			}
		}
	}

	.intro {
		padding 40rpx 30rpx 30rpx 30rpx;
		box-sizing border-box;

		.title {
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			letter-spacing: 1rpx;
		}

		.text {
			margin-top 20rpx;
			text-indent 2em;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #666666;
			line-height: 42rpx;
			letter-spacing: 1rpx;
		}
	}
	.card_panel {
		width 100%;
		display flex;
		flex-wrap wrap;
		padding 0rpx 5rpx 0rpx 30rpx;
		box-sizing border-box;
	
		.card_item {
			width 33.3333%;
			padding-right 25rpx;
			padding-bottom 40rpx;
			box-sizing border-box;
	
			.card_image {
				width: 100%;
				height: 158rpx;
				border-radius: 12rpx;
			}
	
			.card_text {
				margin-top 10rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #333333;
				box-sizing border-box;
			}
		}
	}
</style>
